/**
 * 
 */
package robocup.component.actions;

import java.util.LinkedList;


/**
 * @author wetzker
 *
 */
public class ActionSet {

  private Action main = null;

  private TurnNeckAction neck = null;
  
  private ChangeViewModeAction view = null;
  
  private AttentionToAction attention = null;
  
  private PointToAction pointTo = null;

  private SayAction say = null;
  
  private final LinkedList<Action> actionBuffer = new LinkedList<Action>();
  
  public ActionSet(){}
  
  public void reset(){
    main = null;
    neck = null;
    view = null;
    attention = null;
    pointTo = null;
  }
  
  /**
   * The attention.
   *
   * @return the attention
   */
  public AttentionToAction getAttention() {
  
    return this.attention;
  }

  
  /**
   * Sets the attention
   * 
   * @param attention AttentionToAction, the attention to set
   */
  public void setAttention(final AttentionToAction attention) {
  
    this.attention = attention;
  }

  
  /**
   * The main.
   *
   * @return the main
   */
  public Action getMain() {
  
    return this.main;
  }

  
  /**
   * Sets the main
   * 
   * @param main Action, the main to set
   */
  public void setMain(final Action main) {
  
    this.main = main;
  }

  
  /**
   * The neck.
   *
   * @return the neck
   */
  public TurnNeckAction getNeck() {
  
    return this.neck;
  }

  
  /**
   * Sets the neck
   * 
   * @param neck TurnNeckAction, the neck to set
   */
  public void setNeck(final TurnNeckAction neck) {
  
    this.neck = neck;
  }

  
  /**
   * The pointTo.
   *
   * @return the pointTo
   */
  public PointToAction getPointTo() {
  
    return this.pointTo;
  }

  
  /**
   * Sets the pointTo
   * 
   * @param pointTo PointToAction, the pointTo to set
   */
  public void setPointTo(final PointToAction pointTo) {
  
    this.pointTo = pointTo;
  }

  
  /**
   * The view.
   *
   * @return the view
   */
  public ChangeViewModeAction getView() {
  
    return this.view;
  }

  
  /**
   * Sets the view
   * 
   * @param view ChangeViewModeAction, the view to set
   */
  public void setView(final ChangeViewModeAction view) {
  
    this.view = view;
  }

  
  /**
   * The say.
   *
   * @return the say
   */
  public SayAction getSay() {
  
    return this.say;
  }

  
  /**
   * Sets the say
   * 
   * @param say SayAction, the say to set
   */
  public void setSay(final SayAction say) {
  
    this.say = say;
  }
  
  /**
   * Appends all action strings to a given buffer.
   * 
   * @param buffer - the buffer
   * @param main - include main action
   * @param neck - include neck action
   * @param view - include view action
   * @param attention - include attentionTo action
   * @param say - include say action
   * @param pointTo - include pointTo action
   */
  public void appendActions(final StringBuffer buffer, 
      final boolean main,
      final boolean neck,
      final boolean view,
      final boolean attention,
      final boolean say,
      final boolean pointTo){
    
    this.actionBuffer.clear();
    
    if(main){
      this.actionBuffer.add(this.main);
    }
    
    if(neck){
      this.actionBuffer.add(this.neck);
    }
    
    if(view){
      this.actionBuffer.add(this.view);
    }
    
    if(attention){
      this.actionBuffer.add(this.attention);
    }
    
    if(say){
      this.actionBuffer.add(this.say);
    }
    
    if(pointTo){
      this.actionBuffer.add(this.pointTo);
    }
    
    for(final Action a : this.actionBuffer){
      if(a != null && a.isWorthSending()){
        buffer.append(a.toString());
      }
    }    
  }
  
}
